#ifndef RELATIONPORT_H
#define RELATIONPORT_H

#include <QGraphicsItemGroup>
#include <QGraphicsEffect>
#include <QGraphicsScene>
#include <limits>

#include "uml/relations/umlrelation.h"
#include "uml/relations/relationgraphicsline.h"
#include "uml/relations/labels/relationlabel.h"
#include "uml/relations/decorators/decorators.h"

class RelationPort : public QGraphicsItemGroup
{
public:
    RelationPort(QGraphicsItem *parent = 0);
    ~RelationPort();

    QPoint itemBorderPoint();
    virtual void setItemBorderPoint(QPoint itemBorderPoint);

    QPoint joinPoint();
    void setJoinPoint(QPoint joinPoint);

    UmlRelation* relation();
    void setRelation(UmlRelation *relation);

    virtual void setPen(QPen pen);

    void setCardinality(UmlCardinality cardinality);

    void setRole(QString role);

    void setDirection(UmlRelation::RelativeItemPosition direction);

    void setLinePen(QPen pen);

    QVariant itemChange(GraphicsItemChange change, const QVariant &value);

protected:
    UmlRelation *_relation;

    DecoratorGraphicsItem _decoratorGraphicsItem;

    QLine _line;

    QPen _linePen;

    QPen _decoratorPen;

    WUmlPalette _palette;

    RelationGraphicsLine _lineGraphicsItem;

    UmlCardinality _cardinality;

    RelationLabel _cardinalityLabel;

    RelationLabel _roleLabel;

    UmlRelation::RelativeItemPosition _direction;

    void updateTextPos();
};

#endif // RELATIONPORT_H
